
#include "AsyncAcceptor.h"

AsyncAcceptor::AsyncAcceptor(void)
: m_accepted(0)
{
}

AsyncAcceptor::~AsyncAcceptor(void)
{
}

void
AsyncAcceptor::handle_accept (const ACE_Asynch_Accept::Result &result)
{
	ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_acceptLock);
	// this will call make_handler to new a Channel and call Channel::open()
	(void)this->ACE_Asynch_Acceptor<Channel>::handle_accept(result);
	if(this->m_accepted)
	{
		printf("Accepted [handler:%d]\n",result.accept_handle());
		//ACE_DEBUG ((LM_DEBUG, "m_connectionMap.current_size : %d \n", m_connectionMap.current_size()));
		m_accepted = 0;
	}
}

Channel*
AsyncAcceptor::make_handler(void)
{
	Channel * ch = new Channel();
	m_accepted = ch;
	return ch;
}